#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <cstring>
using namespace std;

struct qj {
    double l;
    double r;
    bool operator < (qj t) {
        return r < t.r;
    }
} q[100010];

int p[100010];

struct car {
    int d, v, a;
} c[100010];

int main() {
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);
    int t;
    cin >> t;
    while (t--) {
        int n, m, L, V, cur = 0;
        cin >> n >> m >> L >> V;
        for (int i = 1; i <= n; i++) cin >> c[i].d >> c[i].v >> c[i].a;
        for (int i = 1; i <= m; i++) cin >> p[i];
        for (int i = 1; i <= n; i++) {
            int d, v, a;
            double _l, _r;
            d = c[i].d, v = c[i].v, a = c[i].a;
            if (a == 0) {
                if (v > V) {
                    int __l = lower_bound(p + 1, p + m + 1, d) - p;
                    int __r = upper_bound(p + 1, p + m + 1, L) - p - 1;
                    if (__r >= __l && __l <= m) q[++cur] = {d, L};
                }
                continue;
            }
            if (a < 0 && v <= V) continue;
            if (a > 0 && v > V) _l = d, _r = L;
            if (a < 0 && v > V) _l = d, _r = d + 1.0 * (V * V - v * v) / 2.0 / a - 0.0001;
            if (a > 0 && v <= V) _l = 1.0 * (V * V - v * v) / 2.0 / a + 0.0001, _r = L;
            if (_l > _r) continue;
            int __l = lower_bound(p + 1, p + m + 1, _l) - p;
            int __r = upper_bound(p + 1, p + m + 1, _r) - p - 1;
            if (__r >= __l && __l <= m) q[++cur] = {_l, _r};
        }
        n = cur;
        cout << cur << " ";
        sort(q + 1, q + n + 1);
        int ans = 0;
        for (int i = 1; i <= n; i++) {
            int latest = upper_bound(p + 1, p + m + 1, q[i].r) - p - 1;
            ans++;
            while (i <= n && q[i].l <= p[latest]) i++;
        }
        cout << m - ans << endl;
    }
    return 0;
}

/*

1 5 5 15 3
0 3 0
12 4 0
1 1 4
5 5 2
6 4 -4
2 5 8 9 15

*/
